<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
 

<!-- 全局js -->
<script src="${ctx}/assets/js/jquery.min.js"></script>
<script src="${ctx}/assets/js/bootstrap.min.js?v=3.3.6"></script>

<!-- 自定义js -->
<script src="${ctx}/assets/js/content.js?v=1.0.0"></script>
<!-- layer javascript -->
<script src="${ctx}/assets/js/plugins/layer/layer.js"></script> 
<script src="${ctx}/assets/js/plugins/laydate/laydate.js"></script>

<!-- Bootstrap table -->
<script src="${ctx}/assets/js/plugins/bootstrap-table/bootstrap-table.min.js"></script>
<script src="${ctx}/assets/js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
<script src="${ctx}/assets/js/plugins/iCheck/icheck.min.js"></script>
<script src="${ctx}/assets/js/plugins/chosen/chosen.jquery.min.js"></script>
<script src="${ctx}/assets/js/plugins/validate/jquery.validate.min.js"></script>
<script src="${ctx}/assets/js/plugins/sweetalert/sweetalert.min.js"></script>
<script src="${ctx}/assets/js/plugins/ztree/jquery.ztree.core.js"></script>


<script src="${ctx}/assets/js/extJquery.js"></script>




	
<script type="text/javascript">
//ztree onBodyDown
function onBodyDown(event) { 
	if ($(event.target).parents('.ztree-content').length==0) {
		hideMenu();
	}
}
//ztree hideMenu
function hideMenu() {
	$('.ztree-content').fadeOut('fast');
	$('body').unbind('mousedown', onBodyDown);
}
/**
 * 字符串对象是否不为空
 */
function isNotNull(val){
	console.info(val);
	if (val !== null && val !== undefined && val !== '') { 
		return true;
	}else{
		return false;
	}
}

function treeSelect(element,nodes,overrideOnClick,overrideBeforeClick) {
	var obj = $(element);  
	var ztreeContentId = element.id+'Content';
	var ztreeId = element.id+'Ztree';
	if($('#'+ztreeContentId).length==0){ 
		//默认ztree设置
		var defalutZtreeSetting = {view: {dblClickExpand: false},data: {simpleData: {enable: true}},
				callback: {	
					onClick: function(e, treeId, treeNode){
						if (typeof(overrideOnClick) == 'undefined' || overrideOnClick === false) { 
							var obj = $('#'+element.id);
							obj.attr('value', treeNode.name);
							obj.data('value',treeNode.id);
							hideMenu();
						 }
						else if (typeof(overrideOnClick) != 'undefined' && overrideOnClick === true) { 
							 var func=eval(element.id+'onClick');
							 var rtn = func(e, treeId, treeNode);  
	 				     	 if(rtn=== undefined || rtn===true){ 
						     	 hideMenu(); 
	 				     	 } 
						}else{
							alert('without onclick function');
						} 
					},
				beforeClick: function(treeId, treeNode, clickFlag) {
					
					if (typeof(overrideBeforeClick) != 'undefined' && overrideBeforeClick === true) { 
						 var func=eval(element.id+'beforeClick'); 
						 var rtn = func(treeId, treeNode, clickFlag);  
 				     	 return rtn; 
					}
				}
				  
			}
		}; 
 		var width = element.clientWidth;
		var ztreeHtml = '<div id="'+ztreeContentId+'" class="ztree-content" style="display:none; position: absolute; border: 1px solid #24AC7E;z-index:2000; background-color: white">';
		ztreeHtml += '<ul id="'+ztreeId+'" class="ztree" style="margin-top:0; width:'+width+'px;"></ul></div>';
		$('body').append(ztreeHtml);
		$.fn.zTree.init($('#'+ztreeId), defalutZtreeSetting, nodes);
	}
	var objOffset = obj.offset();
	$('#'+ztreeContentId).css({left:objOffset.left + 'px', top:objOffset.top + obj.outerHeight() + 'px'}).slideDown('fast');
	$('body').bind('mousedown', onBodyDown);
}
</script>
